<?php

	include "../conf/config.php";
	$result = mysql_connect($host,$granted_user,$granted_mdp)or die("impossible de se connecter"); 
	$result = mysql_select_db($db_name)or die("ne peut selectioner DB");

	if (!$result) {
 		$message  = 'Requête invalide : ' . mysql_error() . "\n";
		$message .= 'Requête complète : ' . $query;
		die($message);
		echo $message;
	}

	if (isset($_POST['valider'])) {

		if (isset($_POST['valid']) && is_array($_POST['valid']))
		{
			$valid = $_POST['valid'] ;
			foreach ($valid as $key => $value) 
			{
				echo $valid[$key];
				$sql = "UPDATE user SET valide = 1 WHERE id_user='".$key."';";
				$ok = mysql_query($sql); 
				echo $sql." - ".$ok."<br />";
			}
		}
	}
	echo mysql_error();
	$_SESSION['user']['message'] = "Modifications effectuées.";
	$location = 'index.php';
	header('Location: ' . $location);

?>